package br.com.spring.mvc.dao;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import br.com.spring.mvc.entity.Teste;

@Repository("testeDAO")
public class TesteDAO {

	private HibernateTemplate hibernateTemplate;

	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		hibernateTemplate = new HibernateTemplate(sessionFactory);
	}

	public void save(Teste entity) {
		hibernateTemplate.save(entity);
	}
	public void update(Teste entity) {
		hibernateTemplate.update(entity);
	}
	public void delete(Teste entity) {
		hibernateTemplate.delete(entity);
	}
	public Teste findCode() {
		return hibernateTemplate.loadAll(Teste.class).get(0);
	}
//	public TesteEntity findByentityCode(Integer id) {
//		List entitys = hibernateTemplate.find(
//				"from TesteEntity where id = ?", id);
//		return (TesteEntity) entitys.get(0);
//	}
	
}
